/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "fmelaboradas")
@NamedQueries({@NamedQuery(name = "Fmelaboradas.findByIdElaboracion", query = "SELECT f FROM Fmelaboradas f WHERE f.idElaboracion = :idElaboracion"), @NamedQuery(name = "Fmelaboradas.findByFechaElaboracion", query = "SELECT f FROM Fmelaboradas f WHERE f.fechaElaboracion = :fechaElaboracion"), @NamedQuery(name = "Fmelaboradas.findByCantidad", query = "SELECT f FROM Fmelaboradas f WHERE f.cantidad = :cantidad")})
public class Fmelaboradas implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @Column(name = "idElaboracion", nullable = false)
    private Integer idElaboracion;
    @Column(name = "fechaElaboracion")
    @Temporal(TemporalType.DATE)
    private Date fechaElaboracion;
    @Column(name = "cantidad")
    private Integer cantidad;
    @Column(name = "precio")
    private Float precio;
    @OneToMany(mappedBy = "idFMElaboradas")
    private Collection<Lote> loteCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fmelaboradas")
    private Collection<Fmxatencion> fmxatencionCollection;
    @JoinColumn(name = "idFm", referencedColumnName = "idFm")
    @ManyToOne
    private Formulamagistral idFm;

    public Fmelaboradas() {
    }

    public Fmelaboradas(Integer idElaboracion) {
        this.idElaboracion = idElaboracion;
    }

    public Integer getIdElaboracion() {
        return idElaboracion;
    }

    public void setIdElaboracion(Integer idElaboracion) {
        Integer oldIdElaboracion = this.idElaboracion;
        this.idElaboracion = idElaboracion;
        changeSupport.firePropertyChange("idElaboracion", oldIdElaboracion, idElaboracion);
    }

    public Date getFechaElaboracion() {
        return fechaElaboracion;
    }

    public void setFechaElaboracion(Date fechaElaboracion) {
        Date oldFechaElaboracion = this.fechaElaboracion;
        this.fechaElaboracion = fechaElaboracion;
        changeSupport.firePropertyChange("fechaElaboracion", oldFechaElaboracion, fechaElaboracion);
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        Integer oldCantidad = this.cantidad;
        this.cantidad = cantidad;
        changeSupport.firePropertyChange("cantidad", oldCantidad, cantidad);
    }

    public Float getPrecio() {
        return precio;
    }

    public void setPrecio(Float precio) {
        Float oldPrecio = this.precio;
        this.precio = precio;
        changeSupport.firePropertyChange("precio", oldPrecio, precio);
    }

    public Collection<Lote> getLoteCollection() {
        return loteCollection;
    }

    public void setLoteCollection(Collection<Lote> loteCollection) {
        this.loteCollection = loteCollection;
    }

    public Collection<Fmxatencion> getFmxatencionCollection() {
        return fmxatencionCollection;
    }

    public void setFmxatencionCollection(Collection<Fmxatencion> fmxatencionCollection) {
        this.fmxatencionCollection = fmxatencionCollection;
    }

    public Formulamagistral getIdFm() {
        return idFm;
    }

    public void setIdFm(Formulamagistral idFm) {
        Formulamagistral oldIdFm = this.idFm;
        this.idFm = idFm;
        changeSupport.firePropertyChange("idFm", oldIdFm, idFm);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idElaboracion != null ? idElaboracion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fmelaboradas)) {
            return false;
        }
        Fmelaboradas other = (Fmelaboradas) object;
        if ((this.idElaboracion == null && other.idElaboracion != null) || (this.idElaboracion != null && !this.idElaboracion.equals(other.idElaboracion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "podologia.beansDB.Fmelaboradas[idElaboracion=" + idElaboracion + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
